﻿#region Usings
using System.Collections.Generic;
using System.Data.SqlClient;

#endregion

namespace System.Modules.SQL.Contracts.DTO
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    [Serializable]
    public class Query<T> where T : new()
    {
        #region Constructor
        /// <summary>
        /// 
        /// </summary>
        public Query()
        {
            Parameters = new List<SqlParameter>();
            Context = new T();
        }
        #endregion

        #region Properties
        /// <summary>
        /// 
        /// </summary>
        public T Context { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Object Value { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public List<SqlParameter> Parameters { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int PageNumber { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Boolean Result { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int TotalRecords { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int TotalPages
        {
            get
            {
                return (PageSize > 0) ? (TotalRecords < PageSize) ? 1 : (TotalRecords / PageSize) + (((TotalRecords % PageSize) > 0) ? 1 : 0) : 1;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public string ViewName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public bool Reporting { get; set; }
        #endregion
    }
}
